

var myapp=angular.module('app',['ui.router']);

myapp.config(['$stateProvider','$urlRouterProvider', function ($stateProvider,$urlRouterProvider) {
    $urlRouterProvider.otherwise('/');
    $stateProvider

        .state('reallystory',{
            url:'/reallystory',
            views:{
                'body':{
                    templateUrl:'./tpl/reallystory.tpl.html',
                    controller:'reallystory.ctrl'
                }
            }
        })
        .state('detail',{
            url:'/detail/:randcode',
            views:{
                'body':{
                    templateUrl:'./tpl/detail.tpl.html',
                    controller:'detail.ctrl'
                }
            }
        })
        .state('createstory',{
            url:'/createstory',
            views:{
                'body':{
                    templateUrl:'./tpl/createstory.tpl.html',
                    controller:'createstory.ctrl'
                }
            }
        })
}]);


myapp.controller('myctrl',['$scope',function($scope){

}])

/*真事控制器*/
.controller('reallystory.ctrl',['$scope','myCache', function ($scope,myCache) {
        $scope.sc = function(randcode){
                //console.log(randcode);
                angular.forEach($scope.resllylist, function (date) {
                    //console.log(date);
                    if (date.randcode == randcode) {
                        date.subscription_count = ++date.subscription_count;
                    }
                })
        };

        $scope.tj = function(storyid){
            //console.log(storyid);
            angular.forEach($scope.resllylist, function (date) {
                if (date.storyid == storyid) {
                    date.like_count = ++date.like_count;
                }
            })
        };

        $scope.oby= function (type){
            $scope.order=type;
        };

     myCache.then(function (res) {
        //console.log(res.data.data[0].data);
        $scope.resllylist=res.data.data[0].data;
    });

}])
/*创作控制器*/
.controller('createstory.ctrl',['$scope','myCache1', function ($scope,myCache1) {

        $scope.sc = function(randcode){
            angular.forEach($scope.resllylist, function (date) {
                if (date.randcode == randcode) {
                    date.subscription_count = ++date.subscription_count;
                }
            })
        };
        $scope.tj = function(storyid){
            angular.forEach($scope.resllylist, function (date) {
                if (date.storyid == storyid) {
                    date.like_count = ++date.like_count;
                }
            })
        };
/*排序*/
        $scope.oby= function (type) {
            $scope.order=type;
        };

/*获取数据*/
        myCache1.then(function (res) {
            console.log(res.data.data[0].data);
            $scope.createlist=res.data.data[0].data;
        });
<<<<<<< HEAD
}])

    /*详情页面控制器*/
.controller('detail.ctrl',['$scope','detail', '$stateParams', function ($scope,detail,$stateParams) {
         var randcode=$stateParams.randcode;
         detail.getreally(randcode)
             .then(function(res){
                 $scope.detaillist = res.data
             });

 }]);
=======
}]);
//秘密控制器
myapp.controller('mimi.ctr',['$scope','$http',function ($scope,$http) {
    // 秘密跳转页面的加载更多
    $scope.bl="";
    $scope.click_tz=function () {
        $scope.bl=20;
        $('.more').html("加载结束");
    };
    $http({
        method:"get",
        url:"/api/mimi/get"
    }).then(function (data) {
        $scope.datalist=data.data.data[0].data;
        console.log( $scope.datalist);
    });
}]);
>>>>>>> bdfec7a59cf26d8104ee7ff70bd38d4151c093b1
